
package org.zjt.java.demo;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.HttpStatus;


@SpringBootApplication
@ComponentScan(basePackages = "org.zjt")
public class StormDemoApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(StormDemoApplication.class);
	}
	@Bean
	public EmbeddedServletContainerCustomizer containerCustomizer() {

		return (container -> {
			ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error-page.html");
			ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error-page.html");
			ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error-page.html");

			container.addErrorPages(error401Page, error404Page, error500Page);
		});
	}
	public static void main(String[] args) throws Exception {
		SpringApplication.run(StormDemoApplication.class, args);
	}
}
